<%--
  Created by IntelliJ IDEA.
  User: 郑希希
  Date: 2024/12/26
  Time: 16:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<style type="text/css">
  body{
  padding-top: 200px;
  padding-bottom: 40px;
  background-repeat: no-repeat;
  background-image: url('img/1.jpg');
  background-position: center;
  background-attachment: fixed;
    background-size: cover;
  }
  .radio{
  padding-top: 10px;
  padding-bottom: 10px;
  }
  .form-signin-heading{
  text-align: center;
  }
  .form-signin{
  max-width: 300px;
    padding: 19px 29px 0px;
    margin: 0 auto 20px;
    background-color: #fff;
    border: 1px solid #e5e5e5;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
    -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
         box-shadow: 0 1px 2px rgba(0,0,0,.05);}
    .form-signin .form-signin-heading,
    .form-signin .checkbox{
      margin-bottom: 10px;
  }
    .form-signin input[type="text"],
    .form-signin input[type="password"]{
    font-size: 16px;
    height: auto;
    margin-bottom: 15px;
    padding: 7px 9px;
    }
</style>
<body>
<div class="container">
  <form name="myform" class="form-signin" action="login" method="post" onsubmit="return checkform();">
    <h2 class="form-signin-heading"><font color="grey">宿舍管理系统</font> </h2>
    <input type="hidden" name="action" value="submit">
    <input id="username" name="stucode" class="stucode" placeholder="学号" type="text"><br>
    <input id="password" name="pwd" class="pwd" placeholder="密码" type="password"><br>
    <font id="error" color="red"></font>
    <div style="text-align: center">
      <button class="submitbtn" type="submit">登录</button>&nbsp;&nbsp;&nbsp;
      <button class="resetbtn" type="reset">重置</button>
    </div>
    <p align="center" style="padding-top: 15px;">版权所有 2024web</p>
  </form>
</div>
<%--<script type="text/javascript">
  function checkform(){
    let stucode=document.getElementById("stucode").value;
    let password=document.getElementById("password").value;
    let remember=document.getElementById("remember").checked;
    if (stucode==null||stucode==""){
      document.getElementById("error").innerHTML="学号不能为空";
      return false;
    }
    if (password==null||password==""){
      document.getElementById("error").innerHTML="密码不能为空";
      return false;
    }
    if (remember){
      document.cookie="username="+encodeURIComponent(stucode)+";max-age=31536000;path=/";
    }
    return true;
    window.onload=function (){
      let cookie=document.cookie.split(';');
      let username=null;
    }
  }
</script>--%>
</script>
<script>
<%
  String stucode=request.getParameter("stucode");
  String role=request.getParameter("role");
  session.setAttribute("stucode",stucode);
  session.setAttribute("role",role);
  String error = (String) request.getAttribute("error");
  System.out.println(error);
  if (error != null) {
%>
    setTimeout(function() {
      alert("用户名密码错误")
    }, 200)
<%
  }
%>
</script>
<%--<%--%>
<%--  String stucode=request.getParameter("stucode");--%>
<%--  String password=request.getParameter("pwd");--%>
<%--  //String error=req.getParameter("error");--%>
<%--  if (stucode==null||stucode==""){--%>
<%--    response.getWriter().println("<script>document.getElementById('error').innerHTML='学号不能为空';</script>");--%>
<%--  }--%>
<%--  if (password==null||password==""){--%>
<%--    response.getWriter().println("<script>document.getElementById('error').innerHTML='学号不能为空';</script>");--%>
<%--  }--%>
<%--%>--%>
</body>
</html>
